cmake_minimum_required(VERSION 3.19)
project(Client LANGUAGES CXX)

file(GLOB PB_FILES "./proto/*.proto")

find_package(Qt6 6.5 REQUIRED COMPONENTS Core Widgets)
find_package(Qt6 REQUIRED COMPONENTS Core Protobuf Network)

qt_standard_project_setup()

qt_add_executable(Client
    WIN32 MACOSX_BUNDLE
    main.cpp
    mainwidget.cpp
    mainwidget.h
    mainwidget.ui
    resource.qrc
    mypushbutton.cpp mypushbutton.h pagecontroller.cpp pagecontroller.h
    interviewlistwidget.h interviewlistwidget.cpp interviewlistwidget.ui
    model/data.h
    interviewcard.h interviewcard.cpp interviewcard.ui
    debug.h
    uploaddialog.cpp uploaddialog.h uploaddialog.ui
    interviewdialog.h interviewdialog.cpp interviewdialog.ui
    searchdialog.h searchdialog.cpp searchdialog.ui
    questionlistwidget.h questionlistwidget.cpp questionlistwidget.ui
    questioncard.h questioncard.cpp questioncard.ui
    questiondialog.h questiondialog.cpp questiondialog.ui
    companylistwidget.h companylistwidget.cpp companylistwidget.ui
    companycard.h companycard.cpp companycard.ui
    companydialog.h companydialog.cpp companydialog.ui
    network/netclient.h network/netclient.cpp
    model/datacenter.h model/datacenter.cpp
    proto/base.proto proto/interview.proto

)

target_link_libraries(Client
    PRIVATE
        Qt::Core
        Qt::Widgets
)
target_link_libraries(Client PRIVATE Qt6::Core Qt6::Network)

qt_add_resources(
    Client
    PREFIX "/"
    FILES
    ui
)

qt_add_protobuf(Client PROTO_FILES ${PB_FILES})

include(GNUInstallDirs)

install(TARGETS Client
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

qt_generate_deploy_app_script(
    TARGET Client
    OUTPUT_SCRIPT deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
